<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>demo</title>
    <!-- <script src="https://unpkg.com/vue@next"></script> -->
    <script src="https://unpkg.com/vue@3.0.5/dist/vue.global.js"></script>
  </head>
  <body>
    <div id="app"></div>
    <script>
      const app = Vue.createApp({
        data() {
          return {
            count: 0,
            b: `<b>加粗</b>`,
          };
        },
        beforeCreate() {
          console.log("实例生成前");
        },
        created() {
          console.log("实例生成后");
        },
        beforeMount() {
          console.log("渲染前");
        },
        mounted() {
          console.log("渲染后");
        },
        beforeUpdate() {
          console.log("更新前");
        },
        updated() {
          console.log("更新后");
        },
        beforeUnmount() {
          console.log("卸载前");
        },
        unmounted() {
          console.log("卸载后");
        },
        methods: {
          add() {
            //vm == this
            this.count++;
          },
          close() {
            app.unmount();
          },
        },
        template: `
          <div>
            hello
            <div>{{count}}</div>
            <button @click='add'>+1</button>
            <button @click='close'>卸载组件</button>
          </div>
        `,
      });

      const vm = app.mount("#app");
    </script>
  </body>
</html>
